﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Tencent.OA.ACM.Entity.RouteInfoCondition>" %>

<%@ Import Namespace="Tencent.OA.ACM.Entity" %>
<%@ Import Namespace="Tencent.OA.ACM.App" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeaderPlaceHolder" runat="server">
<script type="text/javascript">
    var ROUTE_TYPE = [];
    var VEHICLE = [];
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContainerPlaceHolder" runat="server">
    <%
        IList<RouteInfo> list = this.Model.DataList.PagedList as IList<RouteInfo>;
    %>
    <div class="title ">
        <%
            if (list != null && list.Count > 0 && ViewData["CityID"] != null && ViewData["TypeID"] != null)
            {
        %>
        <%= list[0].CityName %>&nbsp;&nbsp;--&nbsp;&nbsp;<%=list[0].BusTypeName%>
        <%
            }
            else
            {
        %>
        全部路线
        <%
            }
        %>
        &nbsp;&nbsp;&nbsp;&nbsp;<a target=_blank href=<%= this.Url.Action("DownExcel","Home") %> style="float:none">【下载所有路线及站点】</a>
    </div>
    <div style="width: 650px; float: left;">
        <table id="myFault" class="tblData" cellpadding="0" cellspacing="0" style="width: 100%">
            <thead>
                <tr class="lt_head">
                    <th>
                        路线
                    </th>
                    <th>
                        台次
                    </th>
                    <th>
                        <span style="width: 500px; vertical-align: top; word-break: break-all; word-wrap: break-word;">
                            具体路线                        
                        </span>
                    </th>
                </tr>
            </thead>
            <tbody id="gvList">
                <%                    
                    if (list == null || list.Count() == 0)
                    {
                %>
                <%=this.Html.ListTableNoResultMessage(list,5) %>
                <%
                    }
                %>
                <% foreach (var item in list)
                   { %>
                <tr>
                    <td style="width:150px;">
                        <a href="<%=this.Url.Content("~/Home/RouteView?rid="+item.RouteId) %>">
                            <%= item.RouteName %></a>
                    </td>
                    <td>
                        <%= item.BusNumber %>
                    </td>
                    <td class="td_routedtl">
                        <div>
                         <div class="routetype" style="float:left; width:220px;">
                          <%= item.CityName %>&nbsp;--&nbsp;<%= item.BusTypeName %>
                         </div>        
                          <div style="float:right; width:190px;">
                             <a href="#" onclick='newFocus("<%=item.RouteId %>",null)';>关注此路线</a> 
                             &nbsp;&nbsp;&nbsp;
                             <a href="javascript:;" onclick="sendToMyPhone('<%=item.RouteId %>')">发送到我的手机</a>
                         </div>   
                        </div>     
                        <div class="routetdtl" style=" clear:both;">
                            <%= Tencent.OA.ACM.Controllers.StationInfoController.GetStationInfoByRouteID(item.RouteId) %>
                        </div>
                        <div class="routeattachinfo" style=" width:380px; float:left; text-align:left;">
                            可容纳
                            <%= item.MaxPeoples %>
                            人，每<%= item.WorkingWeekDisp %>
                            运行
                        </div>
                        <div class="routeattachinfo" style=" width:430px; float:left; text-align:left;">
                          <a title="<%=item.Remark%>" style="text-decoration:none;"><%=string.IsNullOrEmpty(item.Remark) ? "" : "备注：" + Html.LimitStringLength(item.Remark, 35)%></a>
                        </div>
                    </td>
                </tr>
                <% } %>
            </tbody>
        </table>
        <!--翻页 Start-->
       <%-- <div class="paging">
            <%=Html.Pager(this.Model.DataList)%>
        </div>--%>
    </div>
    <div class="block_route_type" id="dv_routeTYpe">
        <div>
            温馨提示<br />
            您可以按<b>CTRL+ F</b>进行查询。
            <div id="block_vehicle">
            
            </div>
        </div>  
        <div class="block_route_section">
        <div class="block_city" id="all_routes"><a href="<%=this.Url.Content("~/StaffRoute/RoutePartion")%>">全部路线</a> </div>
        </div>     
    </div>
    
    <div class="clear">
    </div>

    <script language="javascript">
        function loadJS() {
            var rtjsf = '<%=this.Url.Content("~/caches/base_info/routeType.js") %>';
            var vehiclejsf = '<%=this.Url.Content("~/caches/base_info/vehicle.js") %>';
            
        var rtjs = $.ajax({
                url: rtjsf+"?rd="+Math.random(),
                async: false,
                dataType: "json"
            }).responseText;
            try {
                ROUTE_TYPE = eval("(" + rtjs + ")");
            } catch (ex) { ROUTE_TYPE = []; }

        var vehiclejs = $.ajax({
                url: vehiclejsf + "?rd=" + Math.random(),
                async: false,
                dataType: "json"
            }).responseText;
            try {
                VEHICLE = eval( vehiclejs );
            } catch (ex) { VEHICLE = []; }
        }
        
        $(document).ready(function() {
            loadJS();
            initVehicle();
            initType();
            setLinkStyle();
        });
        var cid = '<%=ViewData["CityID"] %>' ;
        var tid = '<%= ViewData["TypeID"]%>';
        function initType() {           
            var dvType = $("#dv_routeTYpe");
            if (typeof (ROUTE_TYPE) != "undefined" && ROUTE_TYPE.length > 0) {
                var html = '';
                //城市循环
                $.each(ROUTE_TYPE, function(n, o) {
                    html = html + '<div class="block_route_section">';
                    html = html + '<div class="block_city">' + o.cityName + '</div>';
                    //班车类型循环
                    $.each(o.busType, function(m, b) {
                    html = html + '<div class="block_bus_type" cid="' + b.CityID + '" tid="' + b.BusTypeID + '">'
                                + '<a href="javascript:;" onclick=goToType("' + b.CityID + '","' + b.BusTypeID + '")>'
                                + b.BusTypeName 
                                +'</a>'
                                + '</div>';
                    });
                    html = html + '</div>';
                })
                dvType.append(html);
            }
        }
        function initVehicle()
        {
            var dvVehicle=$("#block_vehicle");
            $.each(VEHICLE,function(n,o){
                var html = '<a href="<%=this.Url.Content("~/StaffRoute/VehiclePartion?vId=")%>'
                              + o.veId
                              + '">'
                              + o.veName
                              + '</a><br/>';
                dvVehicle.append(html);
            });
        }
        function goToType(pcid, ptid) {
            if (pcid == cid && ptid == tid)
                return false;
            window.location = '<%=this.Url.Content("~/StaffRoute/RoutePartion")%>?cid='
                                + pcid
                                + '&tid='
                                + ptid;
        }
        function setLinkStyle() {
            if (!cid && !tid) {
                $("#all_routes").addClass("block_bus_type_cur");
                return;
            }
            $(".block_bus_type").each(function() {
                if ($(this).attr("cid") == cid && $(this).attr("tid") == tid) {
                    $(this).addClass("block_bus_type_cur");
                }
            });
        }
    </script>

</asp:Content>
